﻿//-----------------------------------------------------------------------
// <copyright file="CoolNode.cs" company="AFS">
// Copyright (c) AFS. All rights reserved.
//
//    This file is part of Chatbox.
//
//    Chatbox is free software: you can redistribute it and/or modify
//    it under the terms of the GNU Lesser General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    any later version.
//
//    Chatbox is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//    GNU Lesser General Public License for more details.
//
//    You should have received a copy of the GNU Lesser General Public License
//    along with Chatbox. If not, see http://www.gnu.org/copyleft/lesser.html
// </copyright>
//----------------------------------------------------------------------- 

namespace ChatBox.DomainObjects.XmlFeedObjects
{
    /// <summary>
    /// Data on a cooled node
    /// </summary>
    public class CoolNode
    {
        /// <summary>
        /// Gets or sets the writeup that was cooled 
        /// </summary>
        public Link Writeup { get; set; }

        /// <summary>
        /// Gets or sets the writeup author
        /// </summary>
        public Link Author { get; set; }

        /// <summary>
        /// Gets or sets who cooled the writeup
        /// </summary>
        public Link CooledBy { get; set; }

        /// <summary>
        /// Display the cool node for debug
        /// </summary>
        /// <returns>the cool node described as a string</returns>
        public override string ToString()
        {
            return this.Writeup + " by " + this.Author + " cooled by " + this.CooledBy;
        }

        /// <summary>
        /// Equality test
        /// </summary>
        /// <param name="obj">the object to test</param>
        /// <returns>true if they are equivalent</returns>
        public override bool Equals(object obj)
        {
            CoolNode otherCoolNode = obj as CoolNode;
            if (otherCoolNode == null)
            {
                return false;
            }

            return this.Writeup.Equals(otherCoolNode.Writeup) &&
                this.Author.Equals(otherCoolNode.Author) &&
                this.CooledBy.Equals(otherCoolNode.CooledBy);
        }

        /// <summary>
        /// Gets the hash code
        /// </summary>
        /// <returns>the hash code</returns>
        public override int GetHashCode()
        {
            return this.Writeup.GetHashCode() + this.Author.GetHashCode() + this.CooledBy.GetHashCode();
        }
    }
}
